package com.xcity.game.equip.suit4.impl;

import com.xcity.game.combat.ActionEffect;
import com.xcity.game.combat.attr.CombatAttributeType;
import com.xcity.game.combat.unit.CombatUnit;
import com.xcity.game.common.GameStaticConfig;
import com.xcity.game.equip.suit4.BaseSuit4;
import com.xcity.game.equip.template.EquipSuitEffectTemplate;

/**
 * 唐纳卡兰4件套<br/>
 * 造成的伤害{20}%转换为自身生命值
 * @author yang.li
 *
 */
public class Suit4DonaldKaran extends BaseSuit4 {

	public Suit4DonaldKaran(CombatUnit unit, EquipSuitEffectTemplate template) {
		super(unit, template);
	}

	@Override
	public void afterDamage0(ActionEffect effect) {
		if (unit.getId() != effect.ref().getUnitId()) {
			return;
		}
		int hpDelta = (int) (-effect.getHpDelta() * template.getSuit4Param(0) / GameStaticConfig.percentBase);
		if (hpDelta > 0) {
			ActionEffect eff = effect.ref().addTarget(effect.ref().unit);
			eff.effect(CombatAttributeType.HP, hpDelta);
		}
	}

}
